﻿using System.Text;

namespace DbUpgrader.Apis.HashComputers.MD5
{
    public class MD5HashComputer : IHashComputer
    {
        private System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();

        public string ComputeHash(string request)
        {
            byte[] hash = md5.ComputeHash(Encoding.ASCII.GetBytes(request));

            var sb = new StringBuilder();
            for (int i = 0; i < hash.Length; i++)
                sb.Append(hash[i].ToString("X2"));
            return sb.ToString();
        }
    }
}